<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>环绕弹测试</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            background: #000;
            color: #fff;
            font-family: Arial, sans-serif;
        }
        canvas {
            border: 1px solid #333;
            display: block;
            margin: 20px auto;
        }
        .controls {
            text-align: center;
            margin: 20px;
        }
        button {
            padding: 10px 20px;
            margin: 5px;
            background: #333;
            color: #fff;
            border: 1px solid #555;
            cursor: pointer;
        }
        button:hover {
            background: #555;
        }
        .info {
            text-align: center;
            margin: 10px;
            color: #ccc;
        }
    </style>
</head>
<body>
    <div class="info">
        <h2>环绕弹测试</h2>
        <p>使用WASD键移动玩家，观察环绕弹是否正常触发和移动</p>
    </div>
    
    <div class="controls">
        <button onclick="addOrbitalWeapon()">添加环绕弹武器</button>
        <button onclick="resetGame()">重置游戏</button>
        <button onclick="toggleDebug()">切换调试信息</button>
    </div>
    
    <canvas id="gameCanvas" width="800" height="600"></canvas>
    
    <div class="info">
        <p>调试信息：</p>
        <div id="debugInfo"></div>
    </div>

    <!-- 加载游戏脚本 -->
    <script src="js/utils.js"></script>
    <script src="js/sprite.js"></script>
    <script src="js/sprites.js"></script>
    <script src="js/pixelArt.js"></script>
    <script src="js/soundGenerator.js"></script>
    <script src="js/uiAssets.js"></script>
    <script src="js/player.js"></script>
    <script src="js/enemy.js"></script>
    <script src="js/weapon.js"></script>
    <script src="js/item.js"></script>
    <script src="js/minion.js"></script>
    <script src="js/clone.js"></script>
    <script src="js/performance.js"></script>
    <script src="js/ui.js"></script>
    <script src="js/game.js"></script>

    <script>
        let game;
        let debugMode = true;
        
        // 初始化游戏
        async function initGame() {
            // 初始化全局对象
            window.pixelArtGenerator = new PixelArtGenerator();
            window.spriteManager = new SpriteManager();
            window.performanceMonitor = new PerformanceMonitor();
            window.memoryManager = new MemoryManager();
            window.particleSystem = new ParticleSystem();
            window.uiManager = new UIManager();
            
            // 创建游戏实例
            game = new Game();
            await game.init();
            
            // 添加环绕弹武器
            addOrbitalWeapon();
            
            // 开始游戏
            game.start();
            
            // 开始调试更新
            updateDebugInfo();
        }
        
        // 添加环绕弹武器
        function addOrbitalWeapon() {
            if (game && game.weaponManager) {
                game.weaponManager.addWeapon(WEAPON_TYPES.ORBITAL);
                console.log('已添加环绕弹武器');
            }
        }
        
        // 重置游戏
        function resetGame() {
            if (game) {
                game.reset();
                addOrbitalWeapon();
            }
        }
        
        // 切换调试模式
        function toggleDebug() {
            debugMode = !debugMode;
            console.log('调试模式:', debugMode ? '开启' : '关闭');
        }
        
        // 更新调试信息
        function updateDebugInfo() {
            if (!game) return;
            
            const debugDiv = document.getElementById('debugInfo');
            if (debugDiv && debugMode) {
                const weaponManager = game.weaponManager;
                const orbitalWeapon = weaponManager ? weaponManager.weapons.find(w => w.type === WEAPON_TYPES.ORBITAL) : null;
                
                let debugText = '';
                debugText += `游戏状态: ${game.state}<br>`;
                debugText += `武器数量: ${weaponManager ? weaponManager.weapons.length : 0}<br>`;
                
                if (orbitalWeapon) {
                    debugText += `环绕弹等级: ${orbitalWeapon.level}<br>`;
                    debugText += `环绕弹伤害: ${orbitalWeapon.damage}<br>`;
                    debugText += `环绕弹冷却: ${orbitalWeapon.cooldown}ms<br>`;
                    debugText += `环绕弹数量: ${orbitalWeapon.projectiles.length}/${orbitalWeapon.maxProjectiles}<br>`;
                    debugText += `环绕角度: ${orbitalWeapon.orbitalAngle.toFixed(2)}<br>`;
                    debugText += `环绕半径: ${orbitalWeapon.orbitalRadius}<br>`;
                } else {
                    debugText += '未找到环绕弹武器<br>';
                }
                
                if (game.player) {
                    debugText += `玩家位置: (${Math.round(game.player.x)}, ${Math.round(game.player.y)})<br>`;
                }
                
                debugDiv.innerHTML = debugText;
            }
            
            requestAnimationFrame(updateDebugInfo);
        }
        
        // 页面加载完成后初始化游戏
        window.addEventListener('load', initGame);
    </script>
</body>
</html> 